#include "gtest/gtest.h"
#include "gx_err.h"
#include "gx_tree.h"
#include "gx_hash.h"

int compare(const void* d1,const void* d2)
{
	int a = *(int*)d1;
	int b = *(int*)d2;
	return a-b;
}

TEST(tree_test,testinit)
{
	TREE *t = tree_new(0,0,NULL);
	ASSERT_NE(t,(TREE*)NULL);
	tree_delete(t);
}

TEST(tree_test,testadd)
{
	TREE *t = tree_new(4,0,compare);
	ASSERT_NE(t,(TREE*)NULL);

	for(int i=0;i<100;i++)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		ASSERT_EQ(SUCCESS,tree_add(t,&i,keyword));
	}
	tree_delete(t);

	t = tree_new(4,0,compare);

	for(int i=100;i>0;i--)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		ASSERT_EQ(SUCCESS,tree_add(t,&i,keyword));
	}

	for(int i=100;i>0;i--)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		ASSERT_EQ(DATA_EXIT,tree_add(t,&i,keyword));
	}
	tree_delete(t);
}

TEST(tree_test,stradd)
{
	TREE *t = tree_new(0,4,NULL);
	ASSERT_NE(t,(TREE*)NULL);

	for(int i=0;i<100;i++)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		ASSERT_EQ(SUCCESS,tree_add(t,keyword,&i));
	}

	for(int i=0;i<100;i++)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		ASSERT_EQ(DATA_EXIT,tree_add(t,keyword,&i));
	}

	ASSERT_EQ((unsigned)100,t->count);
	tree_delete(t);

	t = tree_new(0,4,NULL);
	ASSERT_NE(t,(TREE*)NULL);

	for(int i=100;i>0;i--)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		ASSERT_EQ(SUCCESS,tree_add(t,keyword,&i));
	}

	ASSERT_EQ((unsigned)100,t->count);

	for(int i=100;i>0;i--)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		ASSERT_EQ(DATA_EXIT,tree_add(t,keyword,&i));
	}
	ASSERT_EQ((unsigned)100,t->count);
	tree_delete(t);
}

TEST(tree_test,treesearch)
{
	TREE *t = tree_new(4,0,compare);
	ASSERT_NE(t,(TREE*)NULL);

	for(int i=0;i<100;i++)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		ASSERT_EQ(SUCCESS,tree_add(t,&i,keyword));
	}

	for(int i=0;i<100;i++)
	{
		char keyword[100] = {0};
		char *s;
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",i);
		s = (char*)tree_search(t,&i);
		ASSERT_NE(s,(char*)NULL);
		//printf("s:%s,keyword:%s\n",s,keyword);
		ASSERT_EQ(0,strcmp(keyword,s));
	}

	for(int i=100;i<1000;i++)
	{
		char *s;
		s = (char*)tree_search(t,&i);
		ASSERT_EQ((char*)NULL,s);
	}
	tree_delete(t);
}

TEST(tree_test,intrand)
{
	srand(time(NULL));

	SET* set = set_new(1000,sizeof(int));

	TREE *t = tree_new(4,0,compare);
	for(int i=0;i<10000;i++)
	{
		int *key = (int *)malloc(sizeof(int));
		*key = rand()%100;

		if(set_add(set,key) != SUCCESS)
		{
			free(key);
		}
		else
		{
			char keyword[100] = {0};
			snprintf(keyword,sizeof(keyword)-1,"keyword%d",*key);
			tree_add(t,key,keyword);
		}
	}

	for(int i=0;i<10000;i++)
	{
		int *key = (int*)malloc(sizeof(int));
		*key = rand()%100;

		if(set_find(set,key) == 1)
		{
			ASSERT_NE((void*)NULL,tree_search(t,key));
		}
		else
		{
			ASSERT_EQ((void*)NULL,tree_search(t,key));
		}
		free(key);
	}
	set_delete(set,free);
	tree_delete(t);
}


TEST(tree_test,strrand)
{
	srand(time(NULL));
	SET* set = set_new(1000,0);
	TREE *t = tree_new(0,4,compare);
	for(int i=0;i<10000;i++)
	{
		char *key = (char*)malloc(100);
		int tmp = rand()%100;
		memset(key,0,100);
		snprintf(key,99,"keyword%d",tmp);

		if(set_add(set,key) != SUCCESS)
		{
			free(key);
		}
		else
		{
			char keyword[100] = {0};
			snprintf(keyword,sizeof(keyword)-1,"keyword%d",*key);
			tree_add(t,key,&tmp);
		}
	}

	for(int i=0;i<10000;i++)
	{
		char *key = (char*)malloc(100);
		int tmp=rand()%100;

		memset(key,0,100);
		snprintf(key,99,"keyword%d",tmp);


		if(set_find(set,key) == 1)
		{
			ASSERT_NE((void*)NULL,tree_search(t,key));
		}
		else
		{
			ASSERT_EQ((void*)NULL,tree_search(t,key));
		}
		free(key);
	}
	set_delete(set,free);
	tree_delete(t);

}

TEST(tree_test,rool)
{
	int data[7] = {4,2,6,1,3,5,7};
	TREE *tree = tree_new(4,0,compare);
	ASSERT_NE((TREE*)NULL,tree);

	for(int i=0;i<7;i++)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",data[i]);
		ASSERT_EQ(SUCCESS,tree_add(tree,data+i,keyword));
	}

	ASSERT_EQ(4,*(int*)(tree->tree_link->key));

	ASSERT_EQ(2,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(1,*(int*)(tree->tree_link->left->left->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->right->key));

	ASSERT_EQ(6,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->right->left->key));
	ASSERT_EQ(7,*(int*)(tree->tree_link->right->right->key));

	roll_right(&(tree->tree_link));

	ASSERT_EQ(2,*(int*)(tree->tree_link->key));
	ASSERT_EQ(1,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(4,*(int*)(tree->tree_link->right->key));
	EXPECT_EQ(3,*(int*)(tree->tree_link->right->left->key));
	ASSERT_EQ(6,*(int*)(tree->tree_link->right->right->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->right->right->left->key));
	ASSERT_EQ(7,*(int*)(tree->tree_link->right->right->right->key));

	roll_left(&(tree->tree_link));
	ASSERT_EQ(4,*(int*)(tree->tree_link->key));

	ASSERT_EQ(2,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(1,*(int*)(tree->tree_link->left->left->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->right->key));

	ASSERT_EQ(6,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->right->left->key));
	ASSERT_EQ(7,*(int*)(tree->tree_link->right->right->key));

	roll_min_up(&(tree->tree_link));
	ASSERT_EQ(1,*(int*)(tree->tree_link->key));
	ASSERT_EQ(4,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(2,*(int*)(tree->tree_link->right->left->key));
	ASSERT_EQ(6,*(int*)(tree->tree_link->right->right->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->right->right->left->key));
	ASSERT_EQ(7,*(int*)(tree->tree_link->right->right->right->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->right->left->right->key));

	tree_delete(tree);
}

TEST(tree_test,treedelete)
{
	int a[11]={6,4,8,2,5,7,10,1,3,9,11};
	TREE *tree = tree_new(4,0,compare);
	ASSERT_NE((TREE*)NULL,tree);
	int errorcode =-1;

	for(int i=0;i<11;i++)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",a[i]);
		ASSERT_EQ(SUCCESS,tree_add(tree,a+i,keyword));
	}

	ASSERT_EQ(6,*(int*)(tree->tree_link->key));
	ASSERT_EQ(4,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(2,*(int*)(tree->tree_link->left->left->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->left->right->key));
	ASSERT_EQ(1,*(int*)(tree->tree_link->left->left->left->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->left->right->key));

	ASSERT_EQ(8,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(10,*(int*)(tree->tree_link->right->right->key));
	ASSERT_EQ(11,*(int*)(tree->tree_link->right->right->right->key));
	ASSERT_EQ(9,*(int*)(tree->tree_link->right->right->left->key));
	ASSERT_EQ(7,*(int*)(tree->tree_link->right->left->key));

	tree_remove_node(&(tree->tree_link),a+2,compare,&errorcode);
	ASSERT_EQ(SUCCESS,errorcode);

	ASSERT_EQ(6,*(int*)(tree->tree_link->key));
	ASSERT_EQ(4,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(2,*(int*)(tree->tree_link->left->left->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->left->right->key));
	ASSERT_EQ(1,*(int*)(tree->tree_link->left->left->left->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->left->right->key));

	ASSERT_EQ(9,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(10,*(int*)(tree->tree_link->right->right->key));
	ASSERT_EQ(11,*(int*)(tree->tree_link->right->right->right->key));
	ASSERT_EQ(7 ,*(int*)(tree->tree_link->right->left->key));

	tree_remove_node(&(tree->tree_link),a,compare,&errorcode);
	ASSERT_EQ(SUCCESS,errorcode);

	ASSERT_EQ(7,*(int*)(tree->tree_link->key));
	ASSERT_EQ(4,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(2,*(int*)(tree->tree_link->left->left->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->left->right->key));
	ASSERT_EQ(1,*(int*)(tree->tree_link->left->left->left->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->left->right->key));

	ASSERT_EQ(9,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(10,*(int*)(tree->tree_link->right->right->key));
	ASSERT_EQ(11,*(int*)(tree->tree_link->right->right->right->key));

	tree_remove_node(&(tree->tree_link),a+7,compare,&errorcode);
	ASSERT_EQ(SUCCESS,errorcode);

	ASSERT_EQ(7,*(int*)(tree->tree_link->key));
	ASSERT_EQ(4,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(2,*(int*)(tree->tree_link->left->left->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->left->right->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->left->right->key));

	ASSERT_EQ(9,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(10,*(int*)(tree->tree_link->right->right->key));
	ASSERT_EQ(11,*(int*)(tree->tree_link->right->right->right->key));

	tree_remove_node(&(tree->tree_link),a+3,compare,&errorcode);
	ASSERT_EQ(errorcode,SUCCESS);


	ASSERT_EQ(7,*(int*)(tree->tree_link->key));
	ASSERT_EQ(9,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(10,*(int*)(tree->tree_link->right->right->key));
	ASSERT_EQ(11,*(int*)(tree->tree_link->right->right->right->key));

	ASSERT_EQ(4,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->left->right->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->left->key));

	tree_remove_node(&(tree->tree_link),a+9,compare,&errorcode);
	ASSERT_EQ(SUCCESS,errorcode);

	ASSERT_EQ(7,*(int*)(tree->tree_link->key));
	ASSERT_EQ(4,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->left->right->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->left->key));

	ASSERT_EQ(10,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(11,*(int*)(tree->tree_link->right->right->key));

	int data = 4;
	tree_remove_node(&(tree->tree_link),&data,compare,&errorcode);
	ASSERT_EQ(SUCCESS,errorcode);

	ASSERT_EQ(7,*(int*)(tree->tree_link->key));
	ASSERT_EQ(5,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->left->key));
	ASSERT_EQ(10,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(11,*(int*)(tree->tree_link->right->right->key));

	data = 5;
	tree_remove_node(&(tree->tree_link),&data,compare,&errorcode);
	ASSERT_EQ(errorcode,SUCCESS);


	ASSERT_EQ(7,*(int*)(tree->tree_link->key));
	ASSERT_EQ(10,*(int*)(tree->tree_link->right->key));
	ASSERT_EQ(11,*(int*)(tree->tree_link->right->right->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->key));

	data = 11;
	tree_remove_node(&(tree->tree_link),&data,compare,&errorcode);
	ASSERT_EQ(errorcode,SUCCESS);

	ASSERT_EQ(7,*(int*)(tree->tree_link->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->key));
	ASSERT_EQ(10,*(int*)(tree->tree_link->right->key));

	data = 7;
	tree_remove_node(&(tree->tree_link),&data,compare,&errorcode);
	ASSERT_EQ(SUCCESS,errorcode);
	ASSERT_EQ(10,*(int*)(tree->tree_link->key));
	ASSERT_EQ(3,*(int*)(tree->tree_link->left->key));

	data = 3;
	tree_remove_node(&(tree->tree_link),&data,compare,&errorcode);
	ASSERT_EQ(SUCCESS,errorcode);
	ASSERT_EQ(10,*(int*)(tree->tree_link->key));

	data = 10;
	tree_remove_node(&(tree->tree_link),&data,compare,&errorcode);
	ASSERT_EQ(SUCCESS,errorcode);
	ASSERT_EQ(NULL,(tree->tree_link));
	free(tree);
}


TEST(tree_test,remove)
{
	srand(time(NULL));

	for(int j=0;j<1;j++)
	{
		SET* set = set_new(1000,sizeof(int));

		TREE *t = tree_new(4,0,compare);
		for(int i=0;i<100000;i++)
		{
			int *key = (int *)malloc(sizeof(int));
			*key = rand()%10000;

			if(set_add(set,key) != SUCCESS)
			{
				free(key);
			}
			else
			{
				char keyword[100] = {0};
				snprintf(keyword,sizeof(keyword)-1,"keyword%d",*key);
				tree_add(t,key,keyword);
			}
		}
		unsigned count = t->count;

		for(int i=0;i<100000;i++)
		{
			int *key = (int*)malloc(sizeof(int));
			*key = rand()%10000;

			if(set_find(set,key) == 1)
			{
				//printf("here2\n");
				ASSERT_EQ(SUCCESS,tree_remove(t,key));
				count--;
				ASSERT_EQ(count,t->count);
				set_remove(set,key,free);
			}
			else
			{
				//printf("here1\n");
				ASSERT_EQ(NODATA,tree_remove(t,key));
			}
			free(key);
		}
		set_delete(set,free);
		tree_delete(t);
	}
}


TEST(tree_test,addrootproblem)
{
	TREE *tree = tree_new(4,0,compare);
	ASSERT_NE((TREE*)NULL,tree);
	int problem[3] ={0,13,5};

	for(int i=0;i<3;i++)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",problem[i]);
		ASSERT_EQ(tree_add_root(tree,problem+i,keyword),SUCCESS);
		ASSERT_EQ(problem[i],*(int*)tree->tree_link->key);
	}
	tree_delete(tree);
}


TEST(tree_test,addroot)
{
	TREE *tree = tree_new(4,0,compare);
	ASSERT_NE((TREE*)NULL,tree);

	for(int i=0;i<10000;i++)
	{
		int key = rand()%20;
		char keyword[100] = {0};
		//printf("key:%d\n",key);
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",key);
		if(tree_search(tree,&key) == (char*)NULL)
		{
			ASSERT_EQ(tree_add_root(tree,&key,keyword),SUCCESS);
			ASSERT_EQ(key,*(int*)tree->tree_link->key);
		}
		else
			ASSERT_EQ(DATA_EXIT,tree_add_root(tree,&key,keyword));
	}
	tree_delete(tree);
}

TEST(tree_test,addspayproblem)
{
	int data[3] = {16,11,16};
	TREE *tree = tree_new(4,0,compare);
	ASSERT_NE((TREE*)NULL,tree);

	for(int i=0;i<3;i++)
	{
		char keyword[100] = {0};
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",data[i]);
		if(tree_search(tree,data+i) == (char*)NULL)
		{
			ASSERT_EQ(tree_add_spay(tree,data+i,keyword),SUCCESS);
			ASSERT_EQ(data[i],*(int*)tree->tree_link->key);
		}
		else
			ASSERT_EQ(DATA_EXIT,tree_add_spay(tree,data+i,keyword));
	}
	tree_delete(tree);
}


TEST(tree_test,addspay)
{
	TREE *tree = tree_new(4,0,compare);
	ASSERT_NE((TREE*)NULL,tree);

	for(int i=0;i<10000;i++)
	{
		int key = rand()%20;
		char keyword[100] = {0};
//		printf("key:%d\n",key);
		snprintf(keyword,sizeof(keyword)-1,"keyword%d",key);
		if(tree_search(tree,&key) == (char*)NULL)
		{
			ASSERT_EQ(tree_add_spay(tree,&key,keyword),SUCCESS);
			ASSERT_EQ(key,*(int*)tree->tree_link->key);
		}
		else
			ASSERT_EQ(DATA_EXIT,tree_add_spay(tree,&key,keyword));
	}
	tree_delete(tree);
}


TEST(rb_tree_test,add)
{
	RB_TREE *rb_tree = rb_tree_new(4,0,compare,NULL);
	ASSERT_NE(rb_tree,(RB_TREE*)NULL);
	int data=12;
	char keyword[100] = {0};
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->left);
	ASSERT_EQ(NULL,rb_tree->tree_link->right);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	data = 1;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->right);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->left->left);
	ASSERT_EQ(NULL,rb_tree->tree_link->left->right);
	ASSERT_EQ(RED,rb_tree->tree_link->left->color);

	
	data = 9;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->color);

	
	data = 2;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	data=0;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	data=11;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	data=7;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->color);

	data=19;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	data=4;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->color);

	data = 15;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9 ,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->color);

	data = 18;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->color);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9 ,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->right->color);

	data = 5;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->right->left->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->left->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->right->color);

	data = 14;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->right->left->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->left->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	data = 13;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->right->left->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->left->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	data = 10;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->right->left->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->left->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->color);

	data = 16;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->right->left->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->left->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	data = 6;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);


	data = 3;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	ASSERT_EQ(3,*(int*)rb_tree->tree_link->left->right->left->right->key);
	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->left->right->color);

	data = 8;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->left->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(8,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	data = 17;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);


	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->left->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(8,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	ASSERT_EQ(17,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	rb_tree_delete(rb_tree);
}

TEST(rb_tree_test,removenode1)
{
	RB_TREE *rb_tree = rb_tree_new(4,0,compare,NULL);
	ASSERT_NE(rb_tree,(RB_TREE*)NULL);
	int data=12;
	char keyword[100] = {0};
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(SUCCESS,rb_tree_remove(rb_tree,&data));
	ASSERT_EQ(NULL,rb_tree->tree_link);
	rb_tree_delete(rb_tree);
}

TEST(rb_tree_test,removenode2)
{
	RB_TREE *rb_tree = rb_tree_new(4,0,compare,NULL);
	ASSERT_NE(rb_tree,(RB_TREE*)NULL);
	int data=12;
	char keyword[100] = {0};
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=11;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=13;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(SUCCESS,rb_tree_remove(rb_tree,&data));

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->color);

	ASSERT_EQ(NULL,rb_tree->tree_link->right);
	rb_tree_delete(rb_tree);
}


TEST(rb_tree_test,removenode3)
{
	RB_TREE *rb_tree = rb_tree_new(4,0,compare,NULL);
	ASSERT_NE(rb_tree,(RB_TREE*)NULL);

	int data=12;
	char keyword[100] = {0};
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 1;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));
	
	data = 9;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 2;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=0;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=11;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=7;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=19;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=4;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 15;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 18;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 5;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 14;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 13;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 10;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 16;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 6;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 3;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 8;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 17;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);


	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->left->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(8,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	ASSERT_EQ(17,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	data = 14;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_remove(rb_tree,&data));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);


	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->left->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(8,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(17,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);


	rb_tree_delete(rb_tree);
}

TEST(rb_tree_test,removenode4)
{
	RB_TREE *rb_tree = rb_tree_new(4,0,compare,NULL);
	ASSERT_NE(rb_tree,(RB_TREE*)NULL);

	int data=12;
	char keyword[100] = {0};
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 1;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));
	
	data = 9;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 2;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=0;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=11;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=7;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=19;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=4;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 15;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 18;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 5;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 14;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 13;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 10;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 16;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 6;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 3;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 8;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 17;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);


	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->left->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(8,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	ASSERT_EQ(17,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	data = 18;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_remove(rb_tree,&data));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);


	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->left->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(8,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	ASSERT_EQ(17,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	rb_tree_delete(rb_tree);
}

TEST(rb_tree_test,removenode5)
{
	RB_TREE *rb_tree = rb_tree_new(4,0,compare,NULL);
	ASSERT_NE(rb_tree,(RB_TREE*)NULL);

	int data=12;
	char keyword[100] = {0};
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 1;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 9;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 2;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=0;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=11;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=7;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=19;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data=4;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 15;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 18;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 5;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 14;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 13;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 10;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 16;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 6;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 3;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 8;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	data = 17;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_add(rb_tree,&data,keyword));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);


	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->left->color);

	ASSERT_EQ(2,*(int*)rb_tree->tree_link->left->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(8,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	ASSERT_EQ(17,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	data = 2;
	snprintf(keyword,sizeof(keyword)-1,"keyword%d",data);
	ASSERT_EQ(SUCCESS,rb_tree_remove(rb_tree,&data));

	ASSERT_EQ(9,*(int*)rb_tree->tree_link->key);
	ASSERT_EQ(NULL,rb_tree->tree_link->parent);
	ASSERT_EQ(BLACK,rb_tree->tree_link->color);

	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->color);

	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->color);

	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->left->color);

	ASSERT_EQ(10,*(int*)rb_tree->tree_link->right->left->left->left->key);
	ASSERT_EQ(11,*(int*)rb_tree->tree_link->right->left->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->left->left->left->color);

	ASSERT_EQ(13,*(int*)rb_tree->tree_link->right->left->right->key);
	ASSERT_EQ(12,*(int*)rb_tree->tree_link->right->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->left->right->color);

	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->key);
	ASSERT_EQ(14,*(int*)rb_tree->tree_link->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->color);


	ASSERT_EQ(19,*(int*)rb_tree->tree_link->right->right->right->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->right->color);

	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->key);
	ASSERT_EQ(9,*(int*)rb_tree->tree_link->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->color);

	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->left->color);

	ASSERT_EQ(0,*(int*)rb_tree->tree_link->left->left->left->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->left->color);

	ASSERT_EQ(3,*(int*)rb_tree->tree_link->left->left->right->key);
	ASSERT_EQ(1,*(int*)rb_tree->tree_link->left->left->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->left->right->color);

	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->key);
	ASSERT_EQ(4,*(int*)rb_tree->tree_link->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->color);

	ASSERT_EQ(5,*(int*)rb_tree->tree_link->left->right->left->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->left->color);

	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->key);
	ASSERT_EQ(6,*(int*)rb_tree->tree_link->left->right->right->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->left->right->right->color);

	ASSERT_EQ(8,*(int*)rb_tree->tree_link->left->right->right->right->key);
	ASSERT_EQ(7,*(int*)rb_tree->tree_link->left->right->right->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->left->right->right->right->color);

	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->key);
	ASSERT_EQ(18,*(int*)rb_tree->tree_link->right->right->left->parent->key);
	ASSERT_EQ(BLACK,rb_tree->tree_link->right->right->left->color);

	ASSERT_EQ(15,*(int*)rb_tree->tree_link->right->right->left->left->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->left->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->left->color);

	ASSERT_EQ(17,*(int*)rb_tree->tree_link->right->right->left->right->key);
	ASSERT_EQ(16,*(int*)rb_tree->tree_link->right->right->left->right->parent->key);
	ASSERT_EQ(RED,rb_tree->tree_link->right->right->left->right->color);

	rb_tree_delete(rb_tree);
}
